﻿Rijschool.betalingdetail = function (params)
{
    var viewModel =
    {
        dataSource: ko.observableArray([]), // De betalingen
        naam: ko.observable(''),
        navItems: ko.observableArray([
            {text: "Alles", icon: "arrowleft"} ,
               { text: "", icon: "user"
               }, { text: "Log uit", icon: "close" }]),

        navItemClicked: function (e)
        {
            var c = e.itemData.text;
            if (c == "Alles") {
                Rijschool.app.navigate("betalingen");
            }
            else if (c == "Log uit")
            {
                Rijschool.app.navigate("inlog");
            }
            else
            {
                Rijschool.app.navigate("leerlingdetail/" + params.naam);
            }
            
        },

        LaadLeerling: function (test)
        {
            var leerling = JSON.parse(httpGet("http://" + window.location.host + "/Site/backend/index.php?leerling=" + params.naam ));
            viewModel.naam("Betalingen " + leerling[0]['naam']);
            var res = viewModel.naam().split(" ");
            viewModel.navItems()[1 ]['text'] = "Meer over " + res[1];
            viewModel.dataSource(JSON.parse(httpGet("http://" + window.location.host + "/Site/backend/index.php?betalingenVan=" + params.naam)));
        },

        opslaan: function ()
        {
            Rijschool.app.navigate("betalingen");
        },
    }
    return viewModel;
}